package com.wedata.腾讯;

import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import com.wedata.HttpUtils;

import java.util.HashMap;
import java.util.Map;

public class 微伴助手2 {

    public static void main(String[] args) {
        getUserid2();
    }

    public static void 获取客户列表() {

        Map<String,Object> map = new HashMap();
        map.put("access_token", 微伴助手.getToken2());
        //map.put("phone_number", "18692845317");//13572031750
        map.put("staff_id","wogizUDQAAZoEtX4Qk_UdSraH3fgjRBA");
        //map.put("phone_number", "13572031750");
        //map.put("tag_id", "etgizUDQAAg6lolhMWN6FWBV8EG4qr_A");
        String resultStr = HttpUtil.get("https://open.weibanzhushou.com/open-api/external_user/list", map);
        JSONObject jsonObject = new JSONObject(resultStr);
        System.out.println(jsonObject);

    }
    public static void 给客户添加企业标签() {
        JSONObject body = new JSONObject();
        //body.set("external_user_id", "wmgizUDQAAczCLVdXiDeXVjITj0lldTA");
        body.set("external_user_id", "wmccZ9HAAAkleVd3k8jAMk-egp4BYLZg");
        body.set("staff_id", "wogizUDQAAZoEtX4Qk_UdSraH3fgjRBA");
        body.set("tag_group", "来源App标签同步2");
        body.set("tag_name", "WE+生效会员");
        JSONObject resultStr = HttpUtils.sendPost("https://open.weibanzhushou.com/open-api/tag/remove?access_token="+微伴助手.getToken2(), body);
        System.out.println(resultStr);

    }
    public static void 获取员工列表() {

        Map<String,Object> map = new HashMap();
        map.put("access_token", 微伴助手.getToken2());
        //map.put("phone_number", "18692845317");//13572031750
        //map.put("staff_id","wogizUDQAAZoEtX4Qk_UdSraH3fgjRBA");
        //map.put("phone_number", "13572031750");
        //map.put("tag_id", "etgizUDQAAg6lolhMWN6FWBV8EG4qr_A");
        String resultStr = HttpUtil.get("https://open.weibanzhushou.com/open-api/staff/list", map);
        JSONObject jsonObject = new JSONObject(resultStr);
        System.out.println(jsonObject);

    }

    /**
     * 用微伴的员工ID 去 获取微信的userid
     * 去企业微信交换用户ID
     */
    public static void getUserid() {
        JSONObject body = new JSONObject();
        body.set("open_userid_list", new String[]{"wogizUDQAAZoEtX4Qk_UdSraH3fgjRBA"});
        body.set("source_agentid", 1000004);//或者1000005 都是微伴助手应用
        JSONObject resultStr = HttpUtils.sendPost("https://qyapi.weixin.qq.com/cgi-bin/batch/openuserid_to_userid?access_token="+ 企业微信.postRequestWithSign(), body);
        //{"errcode":0,"errmsg":"ok","invalid_open_userid_list":[],"userid_list":[{"userid":"YangLin","open_userid":"wogizUDQAAZoEtX4Qk_UdSraH3fgjRBA"}]}
        System.out.println(resultStr);
    }
    /**
     * 用微伴的客户ID  去 获取微信的external_userid
     * 去企业微信交换用户ID
     */
    public static void getUserid2() {
        JSONObject body = new JSONObject();
        body.set("external_userid", "wmgizUDQAABGIscgKcmE3WoA2QvLA_vg");
        body.set("source_agentid", 1000004);//或者1000005 都是微伴助手应用
        JSONObject resultStr = HttpUtils.sendPost("https://qyapi.weixin.qq.com/cgi-bin/externalcontact/from_service_external_userid?access_token="+ 企业微信.postRequestWithSign(), body);
        //{"errcode":0,"errmsg":"ok","external_userid":"wmccZ9HAAAQ9rRPez5Y10Z6uPqFvWbDw"}
        System.out.println(resultStr);
    }


}
